
<!DOCTYPE HTML>
<html lang="zh-hans" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>1.Dart语言(1) · Gary的小窝</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        <meta name="author" content="Gary">
        
        
    
    <link rel="stylesheet" href="../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-prism/prism-solarizedlight.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-search-pro/search.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-expandable-chapters/expandable-chapters.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-splitter/splitter.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-tbfed-pagefooter/footer.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-anchor-navigation-ex/style/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-theme-comscore/test.css">
                
            
        

    

    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="dart2.html" />
    
    
    <link rel="prev" href="./" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="输入并搜索" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    写在前面
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../leetcode/">
            
                <a href="../leetcode/">
            
                    
                    Leetcode之旅
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.1" data-path="../leetcode/1.html">
            
                <a href="../leetcode/1.html">
            
                    
                    1.两数之和
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.2" data-path="../leetcode/2.html">
            
                <a href="../leetcode/2.html">
            
                    
                    2.两数相加
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.3" data-path="../leetcode/3.html">
            
                <a href="../leetcode/3.html">
            
                    
                    3.无重复字符的最长子串
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.4" data-path="../leetcode/4.html">
            
                <a href="../leetcode/4.html">
            
                    
                    4.寻找两个有序数组的中位数
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.5" data-path="../leetcode/6.html">
            
                <a href="../leetcode/6.html">
            
                    
                    6.Z字形变换
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.6" data-path="../leetcode/9.html">
            
                <a href="../leetcode/9.html">
            
                    
                    9.回文数
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.7" data-path="../leetcode/11.html">
            
                <a href="../leetcode/11.html">
            
                    
                    11.盛最多水的容器
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.8" data-path="../leetcode/12.html">
            
                <a href="../leetcode/12.html">
            
                    
                    12.整数转罗马数字
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.9" data-path="../leetcode/13.html">
            
                <a href="../leetcode/13.html">
            
                    
                    13.罗马数字转整数
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.10" data-path="../leetcode/14.html">
            
                <a href="../leetcode/14.html">
            
                    
                    14.最长公共前缀
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.11" data-path="../leetcode/322.html">
            
                <a href="../leetcode/322.html">
            
                    
                    322.零钱兑换
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.12" data-path="../leetcode/72.html">
            
                <a href="../leetcode/72.html">
            
                    
                    72.编辑距离
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="./">
            
                <a href="./">
            
                    
                    Flutter从入门到放弃
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter active" data-level="1.3.1" data-path="dart1.html">
            
                <a href="dart1.html">
            
                    
                    1.Dart语言(1)
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2" data-path="dart2.html">
            
                <a href="dart2.html">
            
                    
                    2.Dart语言(2)
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.3" data-path="widget1.html">
            
                <a href="widget1.html">
            
                    
                    3.Flutter初始化
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.4" data-path="containerText.html">
            
                <a href="containerText.html">
            
                    
                    4.Container和Text组件
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.5" data-path="image.html">
            
                <a href="image.html">
            
                    
                    5.Image组件
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.6" data-path="chapter2.html">
            
                <a href="chapter2.html">
            
                    
                    6.Flutter 技术总结
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="../vue/">
            
                <a href="../vue/">
            
                    
                    Vue组件精讲
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.1" data-path="../vue/1.html">
            
                <a href="../vue/1.html">
            
                    
                    1.provide/inject
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2" data-path="../vue/2.html">
            
                <a href="../vue/2.html">
            
                    
                    2.手动实现broadcast和dispatch方法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.3" data-path="../js/form.html">
            
                <a href="../js/form.html">
            
                    
                    3.自己动手实现带校验的Form表单组件
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="../js/">
            
                <a href="../js/">
            
                    
                    JavaScript进阶
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.1" data-path="../js/proxy.html">
            
                <a href="../js/proxy.html">
            
                    
                    1.Vue.js 3.0中的响应式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.2" data-path="../js/el.html">
            
                <a href="../js/el.html">
            
                    
                    2.Element UI 源码初探
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.3" data-path="../js/bind.html">
            
                <a href="../js/bind.html">
            
                    
                    3.bind的模拟实现
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.4" data-path="../js/proto.html">
            
                <a href="../js/proto.html">
            
                    
                    4.JS原型和原型链
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.5" data-path="../js/call.html">
            
                <a href="../js/call.html">
            
                    
                    5.模拟实现call和apply
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.6" data-path="../js/ui.html">
            
                <a href="../js/ui.html">
            
                    
                    6.使用Vue cli3搭建组件库并发布到 npm
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.7" data-path="../js/microFE.html">
            
                <a href="../js/microFE.html">
            
                    
                    7.记一次基于qiankun的微前端的改造
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.8" data-path="../js/git.html">
            
                <a href="../js/git.html">
            
                    
                    8.Git的使用
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="../vueLibrary/">
            
                <a href="../vueLibrary/">
            
                    
                    基于Vue的PC端的组件库
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.6.1" data-path="../vueLibrary/1.html">
            
                <a href="../vueLibrary/1.html">
            
                    
                    1.环境搭建
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="../life/">
            
                <a href="../life/">
            
                    
                    网事杂谈
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.7.1" data-path="../life/1.html">
            
                <a href="../life/1.html">
            
                    
                    1.周杰伦专辑赏析--叶惠美
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.2" data-path="../life/2.html">
            
                <a href="../life/2.html">
            
                    
                    2.周杰伦专辑赏析--七里香
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            本书使用 GitBook 发布
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >1.Dart语言(1)</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <div id="anchor-navigation-ex-navbar"><i class="fa fa-navicon"></i><ul><li><span class="title-icon "></span><a href="#dart&#x8BED;&#x8A00;"><b></b>Dart&#x8BED;&#x8A00;</a></li><ul><li><span class="title-icon "></span><a href="#1dart&#x91CD;&#x8981;&#x6982;&#x5FF5;"><b></b>1.Dart&#x91CD;&#x8981;&#x6982;&#x5FF5;</a></li><li><span class="title-icon "></span><a href="#&#x53D8;&#x91CF;-&#x57FA;&#x672C;&#x6570;&#x636E;&#x7C7B;&#x578B;"><b></b>&#x53D8;&#x91CF; &#x57FA;&#x672C;&#x6570;&#x636E;&#x7C7B;&#x578B;</a></li><ul><li><span class="title-icon "></span><a href="#var&#x58F0;&#x660E;&#x53D8;&#x91CF;"><b></b>var&#x58F0;&#x660E;&#x53D8;&#x91CF;</a></li><li><span class="title-icon "></span><a href="#&#x53D8;&#x91CF;"><b></b>&#x53D8;&#x91CF;</a></li><li><span class="title-icon "></span><a href="#&#x5E38;&#x91CF;"><b></b>&#x5E38;&#x91CF;</a></li><li><span class="title-icon "></span><a href="#&#x57FA;&#x672C;&#x6570;&#x636E;&#x7C7B;&#x578B;"><b></b>&#x57FA;&#x672C;&#x6570;&#x636E;&#x7C7B;&#x578B;</a></li></ul><li><span class="title-icon "></span><a href="#&#x51FD;&#x6570;"><b></b>&#x51FD;&#x6570;</a></li><ul><li><span class="title-icon "></span><a href="#&#x53C2;&#x6570;&#x9ED8;&#x8BA4;&#x503C;"><b></b>&#x53C2;&#x6570;&#x9ED8;&#x8BA4;&#x503C;</a></li><li><span class="title-icon "></span><a href="#void&#x65E0;&#x8FD4;&#x56DE;&#x503C;"><b></b>void&#x65E0;&#x8FD4;&#x56DE;&#x503C;</a></li><li><span class="title-icon "></span><a href="#&#x533F;&#x540D;&#x51FD;&#x6570;"><b></b>&#x533F;&#x540D;&#x51FD;&#x6570;</a></li><li><span class="title-icon "></span><a href="#&#x8FD0;&#x7B97;&#x7B26;"><b></b>&#x8FD0;&#x7B97;&#x7B26;</a></li></ul><li><span class="title-icon "></span><a href="#&#x6D41;&#x7A0B;&#x63A7;&#x5236;"><b></b>&#x6D41;&#x7A0B;&#x63A7;&#x5236;</a></li><li><span class="title-icon "></span><a href="#dart&#x8BED;&#x8A00;&#x4E2D;&#x7684;&#x5F02;&#x6B65;"><b></b>Dart&#x8BED;&#x8A00;&#x4E2D;&#x7684;&#x5F02;&#x6B65;</a></li><ul><li><span class="title-icon "></span><a href="#future&#x4ECB;&#x7ECD;"><b></b>Future&#x4ECB;&#x7ECD;</a></li><li><span class="title-icon "></span><a href="#&#x666E;&#x901A;&#x5F02;&#x6B65;&#x6848;&#x4F8B;"><b></b>&#x666E;&#x901A;&#x5F02;&#x6B65;&#x6848;&#x4F8B;</a></li><li><span class="title-icon "></span><a href="#&#x8017;&#x65F6;&#x5F02;&#x6B65;&#x6848;&#x4F8B;"><b></b>&#x8017;&#x65F6;&#x5F02;&#x6B65;&#x6848;&#x4F8B;</a></li></ul></ul></ul></div><a href="#dart&#x8BED;&#x8A00;" id="anchorNavigationExGoTop"><i class="fa fa-arrow-up"></i></a><h1 id="dart&#x8BED;&#x8A00;"><a name="dart&#x8BED;&#x8A00;" class="anchor-navigation-ex-anchor" href="#dart&#x8BED;&#x8A00;"><i class="fa fa-link" aria-hidden="true"></i></a>Dart&#x8BED;&#x8A00;</h1>
<h2 id="1dart&#x91CD;&#x8981;&#x6982;&#x5FF5;"><a name="1dart&#x91CD;&#x8981;&#x6982;&#x5FF5;" class="anchor-navigation-ex-anchor" href="#1dart&#x91CD;&#x8981;&#x6982;&#x5FF5;"><i class="fa fa-link" aria-hidden="true"></i></a>1.Dart&#x91CD;&#x8981;&#x6982;&#x5FF5;</h2>
<p>Dart&#x8BED;&#x8A00;&#x662F;Google&#x5728;2011&#x5E74;10&#x6708;&#x5728;&#x4E39;&#x9EA6;&#x4E3E;&#x884C;&#x7684;Goto&#x4F1A;&#x8BAE;&#x4E0A;&#x5BA3;&#x5E03;&#xFF0C;&#x662F;&#x4E00;&#x79CD;&#x7ED3;&#x6784;&#x5316;&#x7684;web&#x7F16;&#x7A0B;&#x8BED;&#x8A00;&#xFF0C;&#x56E0;&#x4E3A;Dart&#x8BED;&#x8A00;&#x62E5;&#x6709;&#x4E00;&#x4E9B;&#x7279;&#x6027;&#xFF0C;&#x4F8B;&#x5982;&#xFF1A; AOT&#x7F16;&#x8F91;&#xFF0C;JIT&#x7F16;&#x8F91;&#xFF0C;&#x53EF;&#x4EE5;&#x8F7B;&#x677E;&#x7684;&#x521B;&#x5EFA;60fps&#x8FD0;&#x884C;&#x7684;&#x6D41;&#x7545;&#x52A8;&#x753B;&#x548C;&#x8F6C;&#x573A;&#x3002;&#x4E0D;&#x9700;&#x8981;&#x5355;&#x72EC;&#x7684;&#x58F0;&#x660E;&#x5F0F;&#x5E03;&#x5C40;&#x8BED;&#x8A00;&#xFF0C;&#x6613;&#x5B66;&#x4E60;&#x7B49;&#x7279;&#x70B9;&#x3002; &#x8FD9;&#x4F7F;&#x5F97;Flutter &#x4F7F;&#x7528;&#x4E86;Dart&#x8FD9;&#x4E2A;&#x8BED;&#x8A00; &#x6210;&#x4E3A;&#x5176;&#x5F00;&#x53D1;&#x8BED;&#x8A00;&#x3002;Dart&#x62E5;&#x6709;&#x51E0;&#x4E2A;&#x6982;&#x5FF5;&#xFF1A;</p>
<ul>
<li>&#x6240;&#x6709;&#x4E1C;&#x897F;&#x90FD;&#x662F;&#x5BF9;&#x8C61;&#xFF0C;&#x6240;&#x6709;&#x7684;&#x5BF9;&#x8C61;&#x90FD;&#x7EE7;&#x627F;&#x81EA;&#x5185;&#x7F6E;&#x7684;Object&#x7C7B;&#x3002;</li>
<li>&#x7A0B;&#x5E8F;&#x4E2D;&#x6307;&#x5B9A;&#x6570;&#x636E;&#x7C7B;&#x578B;&#x4F7F;&#x5F97;&#x7A0B;&#x5E8F;&#x5408;&#x7406;&#x7684;&#x5206;&#x914D;&#x5185;&#x5B58;&#x7A7A;&#x95F4;&#xFF0C;&#x5E76;&#x4E14;&#x5E2E;&#x52A9;&#x7F16;&#x8BD1;&#x5668;&#x8FDB;&#x884C;&#x8BED;&#x6CD5;&#x68C0;&#x67E5;&#x3002;&#x4F46;&#x662F;&#xFF0C;&#x6307;&#x5B9A;&#x7C7B;&#x578B;&#x4E0D;&#x662F;&#x5FC5;&#x987B;&#x7684;&#x3002;Dart &#x662F;&#x5F31;&#x7C7B;&#x578B;&#x8BED;&#x8A00;&#x3002;</li>
<li>Dart&#x4EE3;&#x7801;&#x5728;&#x8FD0;&#x884C;&#x524D;&#x89E3;&#x6790;&#x3002;</li>
<li>Dart&#x7A0B;&#x5E8F;&#x6709;&#x7EDF;&#x4E00;&#x7684;&#x5165;&#x53E3; main() &#x8FD9;&#x4E00;&#x70B9;&#x548C;C C++ &#x5F88;&#x50CF;&#x3002;</li>
<li>Dart&#x8BED;&#x8A00;&#x6CA1;&#x6709;public protected &#x548C; private &#x7684;&#x6982;&#x5FF5;&#x3002; &#x79C1;&#x6709;&#x7279;&#x6027;  &#x901A;&#x8FC7; &#x53D8;&#x91CF; &#x6216;&#x8005;&#x51FD;&#x6570; &#x52A0;&#x4E0A;&#x4E0B;&#x5212;&#x7EBF;&#x8868;&#x793A;&#x3002;</li>
<li>Dart&#x8BED;&#x8A00;&#x652F;&#x6301;async/await &#x5F02;&#x6B65;&#x5904;&#x7406;</li>
</ul>
<h2 id="&#x53D8;&#x91CF;-&#x57FA;&#x672C;&#x6570;&#x636E;&#x7C7B;&#x578B;"><a name="&#x53D8;&#x91CF;-&#x57FA;&#x672C;&#x6570;&#x636E;&#x7C7B;&#x578B;" class="anchor-navigation-ex-anchor" href="#&#x53D8;&#x91CF;-&#x57FA;&#x672C;&#x6570;&#x636E;&#x7C7B;&#x578B;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x53D8;&#x91CF; &#x57FA;&#x672C;&#x6570;&#x636E;&#x7C7B;&#x578B;</h2>
<h3 id="var&#x58F0;&#x660E;&#x53D8;&#x91CF;"><a name="var&#x58F0;&#x660E;&#x53D8;&#x91CF;" class="anchor-navigation-ex-anchor" href="#var&#x58F0;&#x660E;&#x53D8;&#x91CF;"><i class="fa fa-link" aria-hidden="true"></i></a>var&#x58F0;&#x660E;&#x53D8;&#x91CF;</h3>
<blockquote>
<p>&#x7C7B;&#x4F3C;&#x4E8E;kotlin,JS&#x4E2D;&#x7684;var&#xFF0C;&#x5B83;&#x53EF;&#x4EE5;&#x63A5;&#x6536;&#x4EFB;&#x4F55;&#x7C7B;&#x578B;&#x7684;&#x53D8;&#x91CF;&#xFF0C;&#x4F46;&#x6700;&#x5927;&#x7684;&#x4E0D;&#x540C;&#x662F;Dart&#x4E2D;var&#x53D8;&#x91CF;&#x4E00;&#x65E6;&#x8D4B;&#x503C;&#xFF0C;&#x7C7B;&#x578B;&#x4FBF;&#x4F1A;&#x786E;&#x5B9A;&#xFF0C;&#x5219;&#x4E0D;&#x80FD;&#x518D;&#x6539;&#x53D8;&#x5176;&#x7C7B;&#x578B;&#xFF0C;&#x5982;&#xFF1A;</p>
<pre class="language-"><code class="lang-dart"><span class="token keyword">var</span> t<span class="token punctuation">;</span>
t<span class="token operator">=</span><span class="token string">&quot;yc&quot;</span><span class="token punctuation">;</span>
<span class="token comment">// &#x4E0B;&#x9762;&#x4EE3;&#x7801;&#x5728;dart&#x4E2D;&#x4F1A;&#x62A5;&#x9519;&#xFF0C;&#x56E0;&#x4E3A;&#x53D8;&#x91CF;t&#x7684;&#x7C7B;&#x578B;&#x5DF2;&#x7ECF;&#x786E;&#x5B9A;&#x4E3A;String&#xFF0C;</span>
<span class="token comment">// &#x7C7B;&#x578B;&#x4E00;&#x65E6;&#x786E;&#x5B9A;&#x540E;&#x5219;&#x4E0D;&#x80FD;&#x518D;&#x66F4;&#x6539;&#x5176;&#x7C7B;&#x578B;&#x3002;</span>
t<span class="token operator">=</span><span class="token number">1000</span><span class="token punctuation">;</span>
</code></pre>
<p>&#x6700;&#x5927;&#x7684;&#x4E0D;&#x540C;&#x662F;Dart&#x4E2D;var&#x53D8;&#x91CF;&#x4E00;&#x65E6;&#x8D4B;&#x503C;&#xFF0C;&#x7C7B;&#x578B;&#x4FBF;&#x4F1A;&#x786E;&#x5B9A;&#xFF0C;&#x5219;&#x4E0D;&#x80FD;&#x518D;&#x6539;&#x53D8;&#x5176;&#x7C7B;&#x578B;&#x3002;&#x56E0;&#x4E3A;Dart&#x672C;&#x8EAB;&#x662F;&#x4E00;&#x4E2A;&#x5F3A;&#x7C7B;&#x578B;&#x8BED;&#x8A00;&#xFF0C;&#x4EFB;&#x4F55;&#x53D8;&#x91CF;&#x90FD;&#x662F;&#x6709;&#x786E;&#x5B9A;&#x7C7B;&#x578B;&#x7684;&#xFF0C;&#x5728;Dart&#x4E2D;&#xFF0C;&#x5F53;&#x7528;var&#x58F0;&#x660E;&#x4E00;&#x4E2A;&#x53D8;&#x91CF;&#x540E;&#xFF0C;Dart&#x5728;&#x7F16;&#x8BD1;&#x65F6;&#x4F1A;&#x6839;&#x636E;&#x7B2C;&#x4E00;&#x6B21;&#x8D4B;&#x503C;&#x6570;&#x636E;&#x7684;&#x7C7B;&#x578B;&#x6765;&#x63A8;&#x65AD;&#x5176;&#x7C7B;&#x578B;&#xFF0C;&#x7F16;&#x8BD1;&#x7ED3;&#x675F;&#x540E;&#x5176;&#x7C7B;&#x578B;&#x5C31;&#x5DF2;&#x7ECF;&#x88AB;&#x786E;&#x5B9A;&#x3002;</p>
</blockquote>
<h3 id="&#x53D8;&#x91CF;"><a name="&#x53D8;&#x91CF;" class="anchor-navigation-ex-anchor" href="#&#x53D8;&#x91CF;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x53D8;&#x91CF;</h3>
<pre class="language-"><code class="lang-dart"><span class="token keyword">var</span> num <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span>
<span class="token keyword">var</span> title <span class="token operator">=</span> <span class="token string">&quot;&#x6807;&#x9898;&quot;</span><span class="token punctuation">;</span>
</code></pre>
<blockquote>
<p>Dart &#x4E0D;&#x9700;&#x8981;&#x7ED9;&#x53D8;&#x91CF;&#x8BBE;&#x7F6E; setter getter   &#x65B9;&#x6CD5;&#xFF0C; &#x8FD9;&#x548C; kotlin &#x7B49;&#x7C7B;&#x4F3C;&#x3002;Dart &#x4E2D;&#x6240;&#x6709;&#x7684;&#x57FA;&#x7840;&#x7C7B;&#x578B;&#x3001;&#x7C7B;&#x7B49;&#x90FD;&#x7EE7;&#x627F; Object &#xFF0C;&#x9ED8;&#x8BA4;&#x503C;&#x662F; NULL&#xFF0C; &#x81EA;&#x5E26; getter &#x548C; setter &#xFF0C;&#x800C;&#x5982;&#x679C;&#x662F; final &#x6216;&#x8005; const &#x7684;&#x8BDD;&#xFF0C;&#x90A3;&#x4E48;&#x5B83;&#x53EA;&#x6709;&#x4E00;&#x4E2A; getter &#x65B9;&#x6CD5;&#x3002;</p>
</blockquote>
<h3 id="&#x5E38;&#x91CF;"><a name="&#x5E38;&#x91CF;" class="anchor-navigation-ex-anchor" href="#&#x5E38;&#x91CF;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x5E38;&#x91CF;</h3>
<pre class="language-"><code class="lang-dart"><span class="token comment">//final &#x8868;&#x793A;&#x5E38;&#x91CF; &#x53EA;&#x80FD;&#x8BBE;&#x5B9A;&#x4E00;&#x6B21;</span>
<span class="token keyword">final</span> name <span class="token operator">=</span> <span class="token string">&quot;111&quot;</span><span class="token punctuation">;</span>
<span class="token comment">// name = &apos;222&apos; &#x4F1A;&#x5F15;&#x53D1;&#x4E00;&#x4E2A;&#x9519;&#x8BEF;</span>

<span class="token comment">//static const &#x7EC4;&#x5408;&#x4EE3;&#x8868;&#x4E86;&#x9759;&#x6001;&#x5E38;&#x91CF;</span>
<span class="token keyword">static</span> <span class="token keyword">const</span> String complete <span class="token operator">=</span> <span class="token string">&quot;COMPLETE&quot;</span><span class="token punctuation">;</span>
</code></pre>
<blockquote>
<p>final&#x548C;const&#x533A;&#x522B;
&#x4E24;&#x8005;&#x533A;&#x522B;&#x5728;&#x4E8E;&#xFF1A;const &#x53D8;&#x91CF;&#x662F;&#x4E00;&#x4E2A;&#x7F16;&#x8BD1;&#x65F6;&#x5E38;&#x91CF;&#xFF0C;final&#x53D8;&#x91CF;&#x5728;&#x7B2C;&#x4E00;&#x6B21;&#x4F7F;&#x7528;&#x65F6;&#x88AB;&#x521D;&#x59CB;&#x5316;&#x3002;&#x88AB;final&#x6216;&#x8005;const&#x4FEE;&#x9970;&#x7684;&#x53D8;&#x91CF;&#xFF0C;&#x5E76;&#x4E14;&#x53D8;&#x91CF;&#x7C7B;&#x578B;&#x53EF;&#x4EE5;&#x7701;&#x7565;&#x3002;</p>
</blockquote>
<h3 id="&#x57FA;&#x672C;&#x6570;&#x636E;&#x7C7B;&#x578B;"><a name="&#x57FA;&#x672C;&#x6570;&#x636E;&#x7C7B;&#x578B;" class="anchor-navigation-ex-anchor" href="#&#x57FA;&#x672C;&#x6570;&#x636E;&#x7C7B;&#x578B;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x57FA;&#x672C;&#x6570;&#x636E;&#x7C7B;&#x578B;</h3>
<p>Dart&#x8BED;&#x8A00;&#x7684;&#x5E38;&#x7528;&#x7684;&#x57FA;&#x672C;&#x6570;&#x636E;&#x7C7B;&#x578B;&#x5305;&#x62EC;&#xFF1A; Number String  Boolean List Map
Number  String  Boolean  &#x5728;JS&#x4E2D; &#x5F88;&#x719F;&#x6089;&#x4E86;&#x3002; &#x7528;var &#x8FDB;&#x884C;&#x53D8;&#x91CF;&#x8D4B;&#x503C;&#x7684;&#x65F6;&#x5019;&#x4F1A;&#x63A8;&#x65AD;&#x6210;&#x5BF9;&#x5E94;&#x7684;&#x7C7B;&#x578B;</p>
<pre class="language-"><code class="lang-dart"><span class="token keyword">var</span> num <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span>
<span class="token keyword">var</span> title <span class="token operator">=</span> <span class="token string">&quot;&#x6807;&#x9898;&quot;</span><span class="token punctuation">;</span>
<span class="token keyword">var</span> mIsLogin <span class="token operator">=</span> <span class="token boolean">false</span><span class="token punctuation">;</span>
</code></pre>
<p>List &#x5C31;&#x662F;&#x6570;&#x7EC4;</p>
<pre class="language-"><code class="lang-dart">  List arr1 <span class="token operator">=</span> <span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">,</span><span class="token number">2</span><span class="token punctuation">,</span><span class="token number">3</span><span class="token punctuation">,</span><span class="token number">4</span><span class="token punctuation">]</span><span class="token punctuation">;</span>
  <span class="token keyword">var</span> arr2 <span class="token operator">=</span> <span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">,</span><span class="token number">2</span><span class="token punctuation">,</span><span class="token number">3</span><span class="token punctuation">,</span><span class="token number">4</span><span class="token punctuation">]</span><span class="token punctuation">;</span>

  <span class="token function">print</span><span class="token punctuation">(</span>list<span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">//Output: [1, 2, 3, 4]</span>
  <span class="token comment">//Length &#x957F;&#x5EA6;</span>
  <span class="token function">print</span><span class="token punctuation">(</span>list<span class="token punctuation">.</span>length<span class="token punctuation">)</span><span class="token punctuation">;</span>

  <span class="token comment">//Selecting single value &#x83B7;&#x53D6;&#x5355;&#x4E2A;&#x503C;</span>
  <span class="token function">print</span><span class="token punctuation">(</span>list<span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span>    <span class="token comment">//Outout: 2</span>

  <span class="token comment">//Adding a value &#x6DFB;&#x52A0;&#x503C;&#x5230;list</span>
  list<span class="token punctuation">.</span><span class="token function">add</span><span class="token punctuation">(</span><span class="token number">10</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

  <span class="token comment">//Removing a single isntance of value &#x5220;&#x9664;&#x5355;&#x4E2A;&#x503C;</span>
  list<span class="token punctuation">.</span><span class="token function">remove</span><span class="token punctuation">(</span><span class="token number">3</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

  <span class="token comment">//Remove at a particular position &#x5220;&#x9664;&#x6307;&#x5B9A;&#x4F4D;&#x7F6E;&#x7684;&#x503C; &#x7B2C;&#x4E00;&#x4E2A;&#x5143;&#x7D20;&#x7D22;&#x5F15;&#x662F;0&#xFF0C;&#x6700;&#x540E;&#x4E00;&#x4E2A;&#x5143;&#x7D20;&#x662F;length-1</span>

  list<span class="token punctuation">.</span><span class="token function">removeAt</span><span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
</code></pre>
<p>Map</p>
<pre class="language-"><code class="lang-dart">    <span class="token keyword">var</span> map <span class="token operator">=</span> <span class="token punctuation">{</span>
      <span class="token string">&apos;key1&apos;</span><span class="token punctuation">:</span> <span class="token string">&apos;value1&apos;</span><span class="token punctuation">,</span>
      <span class="token string">&apos;key2&apos;</span><span class="token punctuation">:</span> <span class="token string">&apos;value2&apos;</span><span class="token punctuation">,</span>
      <span class="token string">&apos;key3&apos;</span><span class="token punctuation">:</span> <span class="token string">&apos;value3&apos;</span>
    <span class="token punctuation">}</span><span class="token punctuation">;</span>
    <span class="token comment">//Fetching the values &#x83B7;&#x53D6;&#x503C;</span>
    <span class="token function">print</span><span class="token punctuation">(</span>map<span class="token punctuation">[</span><span class="token string">&apos;key1&apos;</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span>    <span class="token comment">//Output: value1</span>
    <span class="token function">print</span><span class="token punctuation">(</span>map<span class="token punctuation">[</span><span class="token string">&apos;test&apos;</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span>    <span class="token comment">//Output: null</span>

    <span class="token comment">//Add a new value &#x6DFB;&#x52A0;&#x503C;</span>
    map<span class="token punctuation">[</span><span class="token string">&apos;key4&apos;</span><span class="token punctuation">]</span> <span class="token operator">=</span> <span class="token string">&apos;value4&apos;</span><span class="token punctuation">;</span>

    <span class="token comment">//Length   &#x83B7;&#x53D6;&#x957F;&#x5EA6;</span>
    <span class="token function">print</span><span class="token punctuation">(</span>map<span class="token punctuation">.</span>length<span class="token punctuation">)</span><span class="token punctuation">;</span>

    <span class="token comment">//Check if a key is present &#x68C0;&#x67E5;&#x662F;&#x5426;&#x5B58;&#x5728;</span>
    <span class="token keyword">var</span> containsKey <span class="token operator">=</span> map<span class="token punctuation">.</span><span class="token function">containsKey</span><span class="token punctuation">(</span><span class="token string">&apos;value1&apos;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token function">print</span><span class="token punctuation">(</span>containsKey<span class="token punctuation">)</span><span class="token punctuation">;</span>

    <span class="token keyword">var</span> entries <span class="token operator">=</span> map<span class="token punctuation">.</span>entries<span class="token punctuation">;</span>
    <span class="token keyword">var</span> values <span class="token operator">=</span> map<span class="token punctuation">.</span>values<span class="token punctuation">;</span>
</code></pre>
<p>&#x4E5F;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;map&#x6784;&#x9020;&#x51FD;&#x6570;&#x5B9A;&#x4E49;map&#x3002;</p>
<pre class="language-"><code class="lang-dart"><span class="token keyword">var</span> squares <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">Map</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
squares<span class="token punctuation">[</span><span class="token string">&quot;a&quot;</span><span class="token punctuation">]</span> <span class="token operator">=</span> <span class="token number">1</span><span class="token punctuation">;</span>
squares<span class="token punctuation">[</span><span class="token string">&quot;b&quot;</span><span class="token punctuation">]</span> <span class="token operator">=</span> <span class="token number">2</span><span class="token punctuation">;</span>
squares<span class="token punctuation">[</span><span class="token string">&quot;c&quot;</span><span class="token punctuation">]</span> <span class="token operator">=</span> <span class="token number">3.0</span><span class="token punctuation">;</span>
squares<span class="token punctuation">[</span><span class="token string">&quot;d&quot;</span><span class="token punctuation">]</span> <span class="token operator">=</span> <span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">,</span><span class="token number">2</span><span class="token punctuation">]</span><span class="token punctuation">;</span>
squares<span class="token punctuation">[</span><span class="token string">&quot;e&quot;</span><span class="token punctuation">]</span> <span class="token operator">=</span> <span class="token string">&quot;yc&#x9017;&#x6BD4;&quot;</span><span class="token punctuation">;</span>

<span class="token function">print</span><span class="token punctuation">(</span>squares<span class="token punctuation">[</span><span class="token string">&apos;a&apos;</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span>    
<span class="token function">print</span><span class="token punctuation">(</span>squares<span class="token punctuation">[</span><span class="token string">&apos;e&apos;</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
</code></pre>
<h2 id="&#x51FD;&#x6570;"><a name="&#x51FD;&#x6570;" class="anchor-navigation-ex-anchor" href="#&#x51FD;&#x6570;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x51FD;&#x6570;</h2>
<p>dart&#x4E2D;&#x7684;&#x51FD;&#x6570;&#x548C;JavaScript&#x4E2D;&#x6709;&#x70B9;&#x7C7B;&#x4F3C;&#x3002;&#x4F60;&#x9700;&#x8981;&#x5B9A;&#x4E49;&#x5C31;&#x662F;&#x51FD;&#x6570;&#x7684;&#x540D;&#x5B57;&#x3001;&#x8FD4;&#x56DE;&#x503C;(&#x6709;&#x8FD4;&#x56DE;&#x503C;&#x6216;&#x8005;void)&#x3001;&#x53C2;&#x6570;&#x3002;</p>
<pre class="language-"><code class="lang-dart"><span class="token keyword">void</span> <span class="token function">test</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
    <span class="token keyword">var</span> name <span class="token operator">=</span> <span class="token function">fullName</span><span class="token punctuation">(</span><span class="token string">&apos;&#x6768;&#x5145;&apos;</span><span class="token punctuation">,</span> <span class="token string">&apos;&#x9017;&#x6BD4;&apos;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token function">print</span><span class="token punctuation">(</span>name<span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token punctuation">}</span>

  String <span class="token function">fullName</span><span class="token punctuation">(</span>String firstName<span class="token punctuation">,</span> String lastName<span class="token punctuation">)</span> <span class="token punctuation">{</span>
    <span class="token keyword">return</span> <span class="token string">&quot;$firstName $lastName&quot;</span><span class="token punctuation">;</span>
  <span class="token punctuation">}</span>
</code></pre>
<h3 id="&#x53C2;&#x6570;&#x9ED8;&#x8BA4;&#x503C;"><a name="&#x53C2;&#x6570;&#x9ED8;&#x8BA4;&#x503C;" class="anchor-navigation-ex-anchor" href="#&#x53C2;&#x6570;&#x9ED8;&#x8BA4;&#x503C;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x53C2;&#x6570;&#x9ED8;&#x8BA4;&#x503C;</h3>
<p>&#x4F60;&#x53EF;&#x4EE5;&#x7ED9;&#x51FD;&#x6570;&#x7684;&#x547D;&#x540D;&#x53C2;&#x6570;&#x4E00;&#x4E2A;&#x9ED8;&#x8BA4;&#x503C;&#x3002;&#x4E0B;&#x9762;&#x7684;&#x4F8B;&#x5B50;&#x7ED9;lastName&#x4E00;&#x4E2A;&#x9ED8;&#x8BA4;&#x503C;&#x3002;</p>
<pre class="language-"><code class="lang-dart">  <span class="token keyword">void</span> <span class="token function">test</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
    <span class="token keyword">var</span> name <span class="token operator">=</span> <span class="token function">fullName</span><span class="token punctuation">(</span><span class="token string">&apos;&#x6768;&#x5145;&apos;</span><span class="token punctuation">,</span> <span class="token string">&apos;&#x9017;&#x6BD4;&apos;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token function">print</span><span class="token punctuation">(</span>name<span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token punctuation">}</span>

  <span class="token function">fullName</span><span class="token punctuation">(</span>String firstName<span class="token punctuation">,</span> String lastName<span class="token punctuation">)</span> <span class="token punctuation">{</span>
    <span class="token keyword">return</span> <span class="token string">&quot;$firstName $lastName&quot;</span><span class="token punctuation">;</span>
  <span class="token punctuation">}</span>
</code></pre>
<h3 id="void&#x65E0;&#x8FD4;&#x56DE;&#x503C;"><a name="void&#x65E0;&#x8FD4;&#x56DE;&#x503C;" class="anchor-navigation-ex-anchor" href="#void&#x65E0;&#x8FD4;&#x56DE;&#x503C;"><i class="fa fa-link" aria-hidden="true"></i></a>void&#x65E0;&#x8FD4;&#x56DE;&#x503C;</h3>
<p>&#x5927;&#x591A;&#x6570;&#x90FD;&#x662F;void&#x65E0;&#x8FD4;&#x56DE;&#x503C;&#x7684;&#x51FD;&#x6570;&#xFF0C;&#x8FD9;&#x4E2A;&#x8DDF;java&#x4E2D;&#x7C7B;&#x4F3C;&#x3002;&#x6CA1;&#x4EC0;&#x4E48;&#x597D;&#x8BB2;&#x7684;&#x2026;&#x2026;</p>
<h3 id="&#x533F;&#x540D;&#x51FD;&#x6570;"><a name="&#x533F;&#x540D;&#x51FD;&#x6570;" class="anchor-navigation-ex-anchor" href="#&#x533F;&#x540D;&#x51FD;&#x6570;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x533F;&#x540D;&#x51FD;&#x6570;</h3>
<p>&#x5728;dart&#x4E2D;&#x51FD;&#x6570;&#x6BD4;&#x8F83;&#x7075;&#x6D3B;&#xFF0C;&#x4F8B;&#x5982;&#xFF0C;&#x4F60;&#x53EF;&#x4EE5;&#x5C06;&#x51FD;&#x6570;&#x5F53;&#x53C2;&#x6570;&#x4F20;&#x9012;&#x7ED9;&#x53E6;&#x4E00;&#x4E2A;&#x51FD;&#x6570;&#x3002;</p>
<pre class="language-"><code class="lang-dart"><span class="token keyword">void</span> <span class="token function">test</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
    <span class="token function">out</span><span class="token punctuation">(</span>printOutLoud<span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token punctuation">}</span>

  <span class="token function">out</span><span class="token punctuation">(</span><span class="token keyword">void</span> <span class="token function">inner</span><span class="token punctuation">(</span>String message<span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
    <span class="token function">inner</span><span class="token punctuation">(</span><span class="token string">&apos;Message from inner function&apos;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token punctuation">}</span>

  <span class="token function">printOutLoud</span><span class="token punctuation">(</span>String message<span class="token punctuation">)</span> <span class="token punctuation">{</span>
    <span class="token function">print</span><span class="token punctuation">(</span>message<span class="token punctuation">.</span><span class="token function">toUpperCase</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token punctuation">}</span>
</code></pre>
<ul>
<li>&#x8FD9;&#x91CC;&#x5B9A;&#x4E49;&#x4E00;&#x4E2A;&#x51FD;&#x6570;&#x540D;&#x5B57;&#x4E3A;out,&#x9700;&#x8981;&#x4E00;&#x4E2A;&#x51FD;&#x6570;&#x53C2;&#x6570;&#x3002;&#x7136;&#x540E;&#x6211;&#x5B9A;&#x4E49;&#x4E00;&#x4E2A;&#x540D;&#x4E3A;printOutLoud&#x7684;&#x51FD;&#x6570;&#xFF0C;&#x4ED6;&#x6240;&#x505A;&#x7684;&#x5C31;&#x662F;&#x5C06;&#x5B57;&#x7B26;&#x4E32;&#x4EE5;&#x5927;&#x5199;&#x7684;&#x5F62;&#x5F0F;&#x6253;&#x5370;&#x3002;</li>
<li>dart &#x4E5F;&#x6709;&#x533F;&#x540D;&#x51FD;&#x6570;&#xFF0C;&#x6240;&#x4EE5;&#x4E0A;&#x9762;&#x7684;&#x4F8B;&#x5B50;&#x4E2D;&#x4E0D;&#x7528;&#x9884;&#x5B9A;&#x4E00;&#x4E2A;&#x51FD;&#x6570;&#xFF0C;&#x800C;&#x662F;&#x4F20;&#x9012;&#x4E00;&#x4E2A;&#x533F;&#x540D;&#x51FD;&#x6570;&#x3002;</li>
</ul>
<h3 id="&#x8FD0;&#x7B97;&#x7B26;"><a name="&#x8FD0;&#x7B97;&#x7B26;" class="anchor-navigation-ex-anchor" href="#&#x8FD0;&#x7B97;&#x7B26;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x8FD0;&#x7B97;&#x7B26;</h3>
<p>&#x548C;java  js &#x8BED;&#x8A00;&#x7C7B;&#x4F3C; &#x4E0D;&#x518D;&#x8D58;&#x8FF0;</p>
<h2 id="&#x6D41;&#x7A0B;&#x63A7;&#x5236;"><a name="&#x6D41;&#x7A0B;&#x63A7;&#x5236;" class="anchor-navigation-ex-anchor" href="#&#x6D41;&#x7A0B;&#x63A7;&#x5236;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x6D41;&#x7A0B;&#x63A7;&#x5236;</h2>
<p>&#x5927;&#x6982;&#x6709;&#x8FD9;&#x4E48;&#x591A; &#x5F88;&#x591A;&#x90FD;&#x548C;JS &#x76F8;&#x540C;</p>
<ul>
<li><p>if&#x548C;else</p>
<pre class="language-"><code class="lang-dart"><span class="token keyword">var</span> number <span class="token operator">=</span> <span class="token number">57</span><span class="token punctuation">;</span>
<span class="token keyword">if</span> <span class="token punctuation">(</span>number <span class="token operator">&gt;</span> <span class="token number">100</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
<span class="token function">print</span><span class="token punctuation">(</span><span class="token string">&apos;Large Number&apos;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span> <span class="token keyword">else</span> <span class="token keyword">if</span> <span class="token punctuation">(</span>number <span class="token operator">&lt;</span> <span class="token number">100</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
<span class="token function">print</span><span class="token punctuation">(</span><span class="token string">&apos;Small Number&apos;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span> <span class="token keyword">else</span> <span class="token punctuation">{</span>
<span class="token function">print</span><span class="token punctuation">(</span><span class="token string">&apos;Number is 100&apos;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
<span class="token comment">/// &#x4E09;&#x5143;&#x8FD0;&#x7B97;&#x7B26;</span>
int age <span class="token operator">=</span> <span class="token number">60</span><span class="token punctuation">;</span>
String status <span class="token operator">=</span> age <span class="token operator">&lt;</span> <span class="token number">50</span> <span class="token operator">?</span> <span class="token string">&quot;&#x5E74;&#x8F7B;&#x4EBA;&quot;</span> <span class="token punctuation">:</span> <span class="token string">&quot;&#x8001;&#x5E74;&#x4EBA;&quot;</span><span class="token punctuation">;</span>
</code></pre>
</li>
<li><p>for&#x5FAA;&#x73AF;</p>
</li>
</ul>
<pre class="language-"><code class="lang-dart">  <span class="token keyword">void</span> <span class="token function">test</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
    <span class="token keyword">for</span> <span class="token punctuation">(</span>int i <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span> i <span class="token operator">&lt;</span> <span class="token number">10</span><span class="token punctuation">;</span> i<span class="token operator">++</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
      <span class="token function">print</span><span class="token punctuation">(</span><span class="token string">&apos;$i&apos;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
  <span class="token punctuation">}</span>
</code></pre>
<ul>
<li>while&#x5FAA;&#x73AF;</li>
</ul>
<pre class="language-"><code class="lang-dart">  <span class="token keyword">void</span> <span class="token function">test</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
    int i <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span>
    <span class="token keyword">while</span><span class="token punctuation">(</span>i <span class="token operator">&lt;</span> <span class="token number">10</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
      <span class="token function">print</span><span class="token punctuation">(</span><span class="token string">&apos;$i&apos;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
      i<span class="token operator">++</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
  <span class="token punctuation">}</span>
<span class="token comment">/// do while</span>
<span class="token keyword">void</span> <span class="token function">test</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
    int i <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span>
    <span class="token keyword">do</span> <span class="token punctuation">{</span>
      <span class="token function">print</span><span class="token punctuation">(</span><span class="token string">&apos;$i&apos;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
      i<span class="token operator">++</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span> <span class="token keyword">while</span> <span class="token punctuation">(</span>i <span class="token operator">&lt;</span> <span class="token number">10</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token punctuation">}</span>
</code></pre>
<ul>
<li><p>break&#x548C;continue</p>
</li>
<li><p>switch&#x548C;case</p>
</li>
</ul>
<pre class="language-"><code class="lang-dart"><span class="token keyword">void</span> <span class="token function">test</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
    int age <span class="token operator">=</span> <span class="token number">50</span><span class="token punctuation">;</span>
    <span class="token keyword">switch</span><span class="token punctuation">(</span>age<span class="token punctuation">)</span> <span class="token punctuation">{</span>
      <span class="token keyword">case</span> <span class="token number">10</span><span class="token punctuation">:</span>
        <span class="token function">print</span><span class="token punctuation">(</span><span class="token string">&apos;Too Young.&apos;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword">break</span><span class="token punctuation">;</span>
      <span class="token keyword">case</span> <span class="token number">20</span><span class="token punctuation">:</span>
      <span class="token keyword">case</span> <span class="token number">30</span><span class="token punctuation">:</span>
        <span class="token function">print</span><span class="token punctuation">(</span><span class="token string">&apos;Still Young!&apos;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword">break</span><span class="token punctuation">;</span>
      <span class="token keyword">case</span> <span class="token number">40</span><span class="token punctuation">:</span>
        <span class="token function">print</span><span class="token punctuation">(</span><span class="token string">&apos;Getting old.&apos;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword">break</span><span class="token punctuation">;</span>
      <span class="token keyword">case</span> <span class="token number">50</span><span class="token punctuation">:</span>
        <span class="token function">print</span><span class="token punctuation">(</span><span class="token string">&apos;You are old!&apos;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword">break</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
  <span class="token punctuation">}</span>
</code></pre>
<ul>
<li>assert&#x65AD;&#x8A00;</li>
</ul>
<h2 id="dart&#x8BED;&#x8A00;&#x4E2D;&#x7684;&#x5F02;&#x6B65;"><a name="dart&#x8BED;&#x8A00;&#x4E2D;&#x7684;&#x5F02;&#x6B65;" class="anchor-navigation-ex-anchor" href="#dart&#x8BED;&#x8A00;&#x4E2D;&#x7684;&#x5F02;&#x6B65;"><i class="fa fa-link" aria-hidden="true"></i></a>Dart&#x8BED;&#x8A00;&#x4E2D;&#x7684;&#x5F02;&#x6B65;</h2>
<h3 id="future&#x4ECB;&#x7ECD;"><a name="future&#x4ECB;&#x7ECD;" class="anchor-navigation-ex-anchor" href="#future&#x4ECB;&#x7ECD;"><i class="fa fa-link" aria-hidden="true"></i></a>Future&#x4ECB;&#x7ECD;</h3>
<ul>
<li>async &#x5E93;&#x4E2D;&#x6709;&#x4E00;&#x4E2A;&#x53EB;Future&#x7684;&#x4E1C;&#x897F;&#x3002;Future&#x662F;&#x57FA;&#x4E8E;&#x89C2;&#x5BDF;&#x8005;&#x6A21;&#x5F0F;&#x7684;&#x3002;&#x5982;&#x679C;&#x4F60;&#x719F;&#x6089;Rx&#x6216;&#x8005;JavaScript&#x7684;Promises&#xFF0C;&#x4F60;&#x5C31;&#x5F88;&#x5BB9;&#x6613;&#x660E;&#x767D;&#x4E86;&#x3002;</li>
</ul>
<p>&#x9996;&#x5148;&#x5148;&#x770B;&#x4E00;&#x4E0B;&#x4E0B;&#x9762;&#x7684;&#x6848;&#x4F8B;&#xFF0C;&#x770B;&#x770B;&#x5B83;&#x4EEC;&#x4E4B;&#x95F4;&#x6709;&#x4EC0;&#x4E48;&#x533A;&#x522B;&#xFF1F;</p>
<pre class="language-"><code class="lang-dart">  <span class="token keyword">void</span> <span class="token function">testA</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token keyword">async</span><span class="token punctuation">{</span>
    <span class="token keyword">new</span> <span class="token class-name">Future</span><span class="token operator">&lt;</span>String<span class="token operator">&gt;</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
      <span class="token keyword">return</span> <span class="token string">&quot;This is a doubi&quot;</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token punctuation">}</span>

  Future <span class="token function">testB</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token keyword">async</span><span class="token punctuation">{</span>
    <span class="token keyword">return</span> <span class="token keyword">new</span> <span class="token class-name">Future</span><span class="token operator">&lt;</span>String<span class="token operator">&gt;</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
      <span class="token keyword">return</span> <span class="token string">&quot;This is a doubi&quot;</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token punctuation">}</span>

  Future<span class="token operator">&lt;</span>String<span class="token operator">&gt;</span> <span class="token function">testC</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
    <span class="token keyword">return</span> <span class="token keyword">new</span> <span class="token class-name">Future</span><span class="token operator">&lt;</span>String<span class="token operator">&gt;</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
      <span class="token keyword">return</span> <span class="token string">&quot;This is a doubi&quot;</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token punctuation">}</span>
</code></pre>
<h3 id="&#x666E;&#x901A;&#x5F02;&#x6B65;&#x6848;&#x4F8B;"><a name="&#x666E;&#x901A;&#x5F02;&#x6B65;&#x6848;&#x4F8B;" class="anchor-navigation-ex-anchor" href="#&#x666E;&#x901A;&#x5F02;&#x6B65;&#x6848;&#x4F8B;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x666E;&#x901A;&#x5F02;&#x6B65;&#x6848;&#x4F8B;</h3>
<ul>
<li><p>Future&#x662F;&#x652F;&#x6301;&#x6CDB;&#x578B;&#x7684;&#xFF0C;&#x4F8B;&#x5982;Future,&#x901A;&#x8FC7;T&#x6307;&#x5B9A;&#x5C06;&#x6765;&#x8FD4;&#x56DE;&#x503C;&#x7684;&#x7C7B;&#x578B;&#x3002;</p>
</li>
<li><p>&#x5B9A;&#x4E49;&#x4E86;&#x4E00;&#x4E2A;&#x53EB;getTest&#x7684;&#x51FD;&#x6570;&#xFF0C;&#x8FD4;&#x56DE;&#x503C;&#x4E3A;Future.&#x4F60;&#x53EF;&#x4EE5;&#x901A;&#x8FC7;new&#x5173;&#x952E;&#x5B57;&#x521B;&#x5EFA;&#x4E00;&#x4E2A;Future&#x3002;Future&#x7684;&#x6784;&#x9020;&#x51FD;&#x6570;&#xFF0C;&#x9700;&#x8981;&#x4E00;&#x4E2A;&#x51FD;&#x6570;&#x4F5C;&#x4E3A;&#x53C2;&#x6570;&#xFF0C;&#x8FD9;&#x4E2A;&#x51FD;&#x6570;&#x8FD4;&#x56DE;T&#x7C7B;&#x578B;&#x7684;&#x6570;&#x636E;&#x3002;&#x5728;&#x533F;&#x540D;&#x51FD;&#x6570;&#x4E2D;&#x7684;&#x8FD4;&#x56DE;&#x503C;&#x5C31;&#x662F;Future&#x7684;&#x8FD4;&#x56DE;&#x503C;&#x3002;</p>
</li>
<li>&#x5F53;&#x8C03;&#x7528;&#x4E86;getTest&#x65B9;&#x6CD5;&#xFF0C;&#x4ED6;&#x8FD4;&#x56DE;Future.&#x6211;&#x4EEC;&#x901A;&#x8FC7;&#x8C03;&#x7528;then&#x65B9;&#x6CD5;&#x8BA2;&#x9605;Future&#xFF0C;&#x5728;then&#x4E2D;&#x6CE8;&#x518C;&#x56DE;&#x8C03;&#x51FD;&#x6570;&#xFF0C;&#x5F53;Future&#x8FD4;&#x56DE;&#x503C;&#x65F6;&#x8C03;&#x7528;&#x6CE8;&#x518C;&#x51FD;&#x6570;&#x3002;&#x540C;&#x65F6;&#x6CE8;&#x518C;&#x4E86;catchError&#x65B9;&#x6CD5;&#x5904;&#x7406;&#x5728;Future&#x6267;&#x884C;&#x4E4B;&#x95F4;&#x53D1;&#x751F;&#x7684;&#x5F02;&#x5E38;&#x3002;&#x8FD9;&#x4E2A;&#x4F8B;&#x5B50;&#x4E2D;&#x4E0D;&#x4F1A;&#x53D1;&#x751F;&#x5F02;&#x5E38;&#x3002;</li>
</ul>
<pre class="language-"><code class="lang-dart">  <span class="token keyword">void</span> <span class="token function">test</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
    <span class="token function">getTest</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">then</span><span class="token punctuation">(</span><span class="token punctuation">(</span>value<span class="token punctuation">)</span> <span class="token punctuation">{</span>
      <span class="token function">print</span><span class="token punctuation">(</span><span class="token string">&quot;&#x6D4B;&#x8BD5;----------&quot;</span><span class="token operator">+</span>value<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">catchError</span><span class="token punctuation">(</span><span class="token punctuation">(</span>error<span class="token punctuation">)</span> <span class="token punctuation">{</span>
      <span class="token function">print</span><span class="token punctuation">(</span><span class="token string">&apos;&#x6D4B;&#x8BD5;----------Error&apos;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token punctuation">}</span>

  Future<span class="token operator">&lt;</span>String<span class="token operator">&gt;</span> <span class="token function">getTest</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
    <span class="token keyword">return</span> <span class="token keyword">new</span> <span class="token class-name">Future</span><span class="token operator">&lt;</span>String<span class="token operator">&gt;</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
      <span class="token keyword">return</span> <span class="token string">&quot;This is a doubi&quot;</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token punctuation">}</span>

  <span class="token comment">//&#x6253;&#x5370;&#x7ED3;&#x679C;</span>
  <span class="token number">2019</span><span class="token operator">-</span><span class="token number">06</span><span class="token operator">-</span><span class="token number">21</span> <span class="token number">17</span><span class="token punctuation">:</span><span class="token number">11</span><span class="token punctuation">:</span><span class="token number">12.941</span> <span class="token number">16501</span><span class="token operator">-</span><span class="token number">16583</span><span class="token operator">/</span>com<span class="token punctuation">.</span>hwmc<span class="token punctuation">.</span>auth I<span class="token operator">/</span>flutter<span class="token punctuation">:</span> &#x6D4B;&#x8BD5;<span class="token operator">--</span><span class="token operator">--</span><span class="token operator">--</span><span class="token operator">--</span><span class="token operator">--</span>This <span class="token operator">is</span> a doubi
</code></pre>
<ul>
<li>&#x4E0B;&#x9762;&#x8FD9;&#x4E2A;&#x6848;&#x4F8B;&#x4F1A;&#x53D1;&#x751F;&#x5F02;&#x5E38;</li>
</ul>
<pre class="language-"><code class="lang-dart">  <span class="token keyword">void</span> <span class="token function">test</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
    <span class="token function">getTest</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">then</span><span class="token punctuation">(</span><span class="token punctuation">(</span>value<span class="token punctuation">)</span> <span class="token punctuation">{</span>
      <span class="token function">print</span><span class="token punctuation">(</span><span class="token string">&quot;&#x6D4B;&#x8BD5;----------&quot;</span><span class="token operator">+</span>value<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">catchError</span><span class="token punctuation">(</span><span class="token punctuation">(</span>error<span class="token punctuation">)</span> <span class="token punctuation">{</span>
      <span class="token function">print</span><span class="token punctuation">(</span><span class="token string">&apos;&#x6D4B;&#x8BD5;----------Error&apos;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token punctuation">}</span>

  Future<span class="token operator">&lt;</span>String<span class="token operator">&gt;</span> <span class="token function">getTest</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
    <span class="token keyword">return</span> <span class="token keyword">new</span> <span class="token class-name">Future</span><span class="token operator">&lt;</span>String<span class="token operator">&gt;</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
      <span class="token keyword">return</span> <span class="token string">&quot;This is a doubi&quot;</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token punctuation">}</span>

  <span class="token comment">//&#x6253;&#x5370;&#x7ED3;&#x679C;</span>
  <span class="token number">2019</span><span class="token operator">-</span><span class="token number">06</span><span class="token operator">-</span><span class="token number">21</span> <span class="token number">17</span><span class="token punctuation">:</span><span class="token number">18</span><span class="token punctuation">:</span><span class="token number">46.896</span> <span class="token number">16501</span><span class="token operator">-</span><span class="token number">16583</span><span class="token operator">/</span>com<span class="token punctuation">.</span>hwmc<span class="token punctuation">.</span>auth I<span class="token operator">/</span>flutter<span class="token punctuation">:</span> &#x6D4B;&#x8BD5;<span class="token operator">--</span><span class="token operator">--</span><span class="token operator">--</span><span class="token operator">--</span><span class="token operator">--</span>Error
</code></pre>
<h3 id="&#x8017;&#x65F6;&#x5F02;&#x6B65;&#x6848;&#x4F8B;"><a name="&#x8017;&#x65F6;&#x5F02;&#x6B65;&#x6848;&#x4F8B;" class="anchor-navigation-ex-anchor" href="#&#x8017;&#x65F6;&#x5F02;&#x6B65;&#x6848;&#x4F8B;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x8017;&#x65F6;&#x5F02;&#x6B65;&#x6848;&#x4F8B;</h3>
<ul>
<li>&#x5728;&#x751F;&#x4EA7;&#x73AF;&#x5883;&#x4E2D;&#x90FD;&#x662F;&#x4E00;&#x4E9B;&#x8017;&#x65F6;&#x7684;&#x64CD;&#x4F5C;&#xFF0C;&#x4F8B;&#x5982;&#xFF0C;&#x7F51;&#x7EDC;&#x8C03;&#x7528;&#xFF0C;&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;Future.delayed()&#x6A21;&#x4EFF;&#x3002;</li>
<li>&#x73B0;&#x5728;&#x5982;&#x679C;&#x4F60;&#x8FD0;&#x884C;&#xFF0C;&#x4F60;&#x5C06;&#x9700;&#x8981;2&#x79D2;&#xFF0C;&#x624D;&#x80FD;&#x8FD4;&#x56DE;&#x7ED3;&#x679C;&#x3002;</li>
</ul>
<pre class="language-"><code class="lang-dart">  <span class="token keyword">void</span> <span class="token function">test</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
    <span class="token function">getTest</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">then</span><span class="token punctuation">(</span><span class="token punctuation">(</span>value<span class="token punctuation">)</span> <span class="token punctuation">{</span>
      <span class="token function">print</span><span class="token punctuation">(</span><span class="token string">&quot;&#x6D4B;&#x8BD5;----------&quot;</span><span class="token operator">+</span>value<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">catchError</span><span class="token punctuation">(</span><span class="token punctuation">(</span>error<span class="token punctuation">)</span> <span class="token punctuation">{</span>
      <span class="token function">print</span><span class="token punctuation">(</span><span class="token string">&apos;&#x6D4B;&#x8BD5;----------Error&apos;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token punctuation">}</span>

  Future<span class="token operator">&lt;</span>String<span class="token operator">&gt;</span> <span class="token function">getTest</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
    <span class="token keyword">return</span> <span class="token keyword">new</span> <span class="token class-name">Future</span><span class="token operator">&lt;</span>String<span class="token operator">&gt;</span><span class="token punctuation">.</span><span class="token function">delayed</span><span class="token punctuation">(</span><span class="token keyword">new</span> <span class="token class-name">Duration</span><span class="token punctuation">(</span>milliseconds<span class="token punctuation">:</span> <span class="token number">2000</span><span class="token punctuation">)</span><span class="token punctuation">,</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
      <span class="token keyword">return</span> <span class="token string">&quot;This is a doubi&quot;</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token punctuation">}</span>
</code></pre>
<ul>
<li>&#x63A5;&#x4E0B;&#x6765;&#x518D;&#x770B;&#x4E00;&#x4E2A;&#x6848;&#x4F8B;&#x3002;&#x5728;&#x8C03;&#x7528;&#x51FD;&#x6570;&#x4E4B;&#x540E;&#xFF0C;&#x6211;&#x4EEC;&#x6DFB;&#x52A0;&#x4E86;print&#x8BED;&#x53E5;&#x3002;&#x5728;&#x8FD9;&#x79CD;&#x573A;&#x666F;&#x4E2D;&#xFF0C;print&#x8BED;&#x53E5;&#x4F1A;&#x5148;&#x6267;&#x884C;&#xFF0C;&#x4E4B;&#x540E;future&#x7684;&#x8FD4;&#x56DE;&#x503C;&#x624D;&#x4F1A;&#x6253;&#x5370;&#x3002;&#x8FD9;&#x662F;future&#x7684;&#x9884;&#x671F;&#x884C;&#x4E3A;.&#x4F46;&#x662F;&#x5982;&#x679C;&#x6211;&#x4EEC;&#x5E0C;&#x671B;&#x5728;&#x6267;&#x884C;&#x5176;&#x4ED6;&#x8BED;&#x53E5;&#x4E4B;&#x524D;&#xFF0C;&#x5148;&#x6267;&#x884C;future&#x3002;</li>
</ul>
<pre class="language-"><code class="lang-dart">  <span class="token keyword">void</span> <span class="token function">test</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
    <span class="token function">getTest</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">then</span><span class="token punctuation">(</span><span class="token punctuation">(</span>value<span class="token punctuation">)</span> <span class="token punctuation">{</span>
      <span class="token function">print</span><span class="token punctuation">(</span><span class="token string">&quot;&#x6D4B;&#x8BD5;----------&quot;</span><span class="token operator">+</span>value<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">catchError</span><span class="token punctuation">(</span><span class="token punctuation">(</span>error<span class="token punctuation">)</span> <span class="token punctuation">{</span>
      <span class="token function">print</span><span class="token punctuation">(</span><span class="token string">&apos;&#x6D4B;&#x8BD5;----------Error&apos;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token function">print</span><span class="token punctuation">(</span><span class="token string">&apos;&#x6D4B;&#x8BD5;----------&#x9017;&#x6BD4;&#x662F;&#x8FD9;&#x4E2A;&#x5148;&#x6267;&#x884C;&#x5417;&apos;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token punctuation">}</span>

  Future<span class="token operator">&lt;</span>String<span class="token operator">&gt;</span> <span class="token function">getTest</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
    <span class="token keyword">return</span> <span class="token keyword">new</span> <span class="token class-name">Future</span><span class="token operator">&lt;</span>String<span class="token operator">&gt;</span><span class="token punctuation">.</span><span class="token function">delayed</span><span class="token punctuation">(</span><span class="token keyword">new</span> <span class="token class-name">Duration</span><span class="token punctuation">(</span>milliseconds<span class="token punctuation">:</span> <span class="token number">2000</span><span class="token punctuation">)</span><span class="token punctuation">,</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
      <span class="token keyword">return</span> <span class="token string">&quot;This is a doubi&quot;</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token punctuation">}</span>

  <span class="token number">2019</span><span class="token operator">-</span><span class="token number">06</span><span class="token operator">-</span><span class="token number">21</span> <span class="token number">17</span><span class="token punctuation">:</span><span class="token number">26</span><span class="token punctuation">:</span><span class="token number">16.619</span> <span class="token number">16501</span><span class="token operator">-</span><span class="token number">16583</span><span class="token operator">/</span>com<span class="token punctuation">.</span>hwmc<span class="token punctuation">.</span>auth I<span class="token operator">/</span>flutter<span class="token punctuation">:</span> &#x6D4B;&#x8BD5;<span class="token operator">--</span><span class="token operator">--</span><span class="token operator">--</span><span class="token operator">--</span><span class="token operator">--</span>&#x9017;&#x6BD4;&#x662F;&#x8FD9;&#x4E2A;&#x5148;&#x6267;&#x884C;&#x5417;
  <span class="token number">2019</span><span class="token operator">-</span><span class="token number">06</span><span class="token operator">-</span><span class="token number">21</span> <span class="token number">17</span><span class="token punctuation">:</span><span class="token number">26</span><span class="token punctuation">:</span><span class="token number">17.176</span> <span class="token number">16501</span><span class="token operator">-</span><span class="token number">16583</span><span class="token operator">/</span>com<span class="token punctuation">.</span>hwmc<span class="token punctuation">.</span>auth I<span class="token operator">/</span>flutter<span class="token punctuation">:</span> &#x6D4B;&#x8BD5;<span class="token operator">--</span><span class="token operator">--</span><span class="token operator">--</span><span class="token operator">--</span><span class="token operator">--</span>This <span class="token operator">is</span> a doubi
</code></pre>
<footer class="page-footer"><span class="copyright">Copyright &#xA9; YoungGary 2019 all right reserved&#xFF0C;powered by Gitbook</span><span class="footer-modification">&#x8BE5;&#x6587;&#x4EF6;&#x4FEE;&#x8BA2;&#x65F6;&#x95F4;&#xFF1A;
2020-01-03 16:31:06
</span></footer>
                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="./" class="navigation navigation-prev " aria-label="Previous page: Flutter从入门到放弃">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="dart2.html" class="navigation navigation-next " aria-label="Next page: 2.Dart语言(2)">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"1.Dart语言(1)","level":"1.3.1","depth":2,"next":{"title":"2.Dart语言(2)","level":"1.3.2","depth":2,"path":"flutter/dart2.md","ref":"flutter/dart2.md","articles":[]},"previous":{"title":"Flutter从入门到放弃","level":"1.3","depth":1,"path":"flutter/README.md","ref":"flutter/README.md","articles":[{"title":"1.Dart语言(1)","level":"1.3.1","depth":2,"path":"flutter/dart1.md","ref":"flutter/dart1.md","articles":[]},{"title":"2.Dart语言(2)","level":"1.3.2","depth":2,"path":"flutter/dart2.md","ref":"flutter/dart2.md","articles":[]},{"title":"3.Flutter初始化","level":"1.3.3","depth":2,"path":"flutter/widget1.md","ref":"flutter/widget1.md","articles":[]},{"title":"4.Container和Text组件","level":"1.3.4","depth":2,"path":"flutter/containerText.md","ref":"flutter/containerText.md","articles":[]},{"title":"5.Image组件","level":"1.3.5","depth":2,"path":"flutter/image.md","ref":"flutter/image.md","articles":[]},{"title":"6.Flutter 技术总结","level":"1.3.6","depth":2,"path":"flutter/chapter2.md","ref":"flutter/chapter2.md","articles":[]}]},"dir":"ltr"},"config":{"plugins":["theme-comscore","prism","-highlight","copy-code-button","search-pro","-search","-lunr","expandable-chapters","splitter","-sharing","tbfed-pagefooter","anchor-navigation-ex"],"styles":{},"pluginsConfig":{"tbfed-pagefooter":{"copyright":"Copyright &copy YoungGary 2019","modify_label":"该文件修订时间：","modify_format":"YYYY-MM-DD HH:mm:ss"},"prism":{"css":["prismjs/themes/prism-solarizedlight.css"],"lang":{"shell":"bash"}},"splitter":{},"search-pro":{},"fontsettings":{"theme":"white","family":"sans","size":2},"anchor-navigation-ex":{"associatedWithSummary":true,"float":{"floatIcon":"fa fa-navicon","level1Icon":"","level2Icon":"","level3Icon":"","showLevelIcon":false},"mode":"float","multipleH1":true,"pageTop":{"level1Icon":"","level2Icon":"","level3Icon":"","showLevelIcon":false},"printLog":false,"showGoTop":true,"showLevel":false},"theme-comscore":{},"copy-code-button":{},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false},"expandable-chapters":{}},"theme":"default","author":"Gary","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"Gary的小窝","language":"zh-hans","gitbook":"*","description":"Gary的小窝. 里面包含了个人撰写的技术文章"},"file":{"path":"flutter/dart1.md","mtime":"2020-01-03T08:31:06.068Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2021-09-09T14:10:10.930Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../gitbook/gitbook.js"></script>
    <script src="../gitbook/theme.js"></script>
    
        
        <script src="../gitbook/gitbook-plugin-copy-code-button/toggle.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search-pro/jquery.mark.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search-pro/search.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-expandable-chapters/expandable-chapters.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-splitter/splitter.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-theme-comscore/test.js"></script>
        
    

    </body>
</html>

